package org.teamh.game;

import org.teamh.connection.Connection;
import org.teamh.gui.InterfaceManager;
import org.teamh.logic.Logic;
import org.teamh.logic.lobby.ModelManager;

/**
 * This is the basic class for the whole game. It can either be used by the
 * graphical client to start the application or by the ai. 
 * 
 * @author richard
 * 
 */
public class Start {

	private Connection connection;
	private InterfaceManager interfaceManager;
	private Logic logic;
	private ModelManager model;
	
	/**
	 * This starts the mainly required threads for the program
	 */
	public void startCore() {
		connection.connect();
		interfaceManager.start();
		logic.start();
	}
	
	/**
	 * Returns the current network connection object. 
	 * @return
	 */
	public Connection getConnection() {
		return connection;
	}
	
	/**
	 * Returns the surface of the game. This is the graphical user interface or the artificial intelligence manager.  
	 * @return
	 */
	public InterfaceManager getGui() {
		return interfaceManager;
	}
	
	/**
	 * Returns the logic of the game. 
	 * @return
	 */
	public Logic getLogic() {
		return logic;
	}
	
	/**
	 * Returns the datamodel of the game. 
	 * @return
	 */
	public ModelManager getModel() {
		return model;
	}
	
	/**
	 * This method requests any main thread to close. 
	 */
	public void exit() {
		
		interfaceManager.close();
		connection.close();
	}
	
	/**
	 * Sets the connection object. 
	 * @param connection
	 */
	public void setConnection(Connection connection) {
		this.connection = connection;
	}
	
	/**
	 * Set the surface object. 
	 * @param interfaceManager
	 */
	public void setInterfaceManager(InterfaceManager interfaceManager) {
		this.interfaceManager = interfaceManager;
	}
	
	/**
	 * sets the logic object. 
	 * @param logic
	 */
	public void setLogic(Logic logic) {
		this.logic = logic;
	}
	
	/**
	 * Sets the model manager object. 
	 * @param model
	 */
	public void setModel(ModelManager model) {
		this.model = model;
	}
}
